<?php
namespace Admin\Controller;
class MyMemberDetailController extends AdminController {
	// 用书查询和列表
	public function userlist()
	{  
    // 获取排序条件
    $content = null != (string)(I('request.sort')) ? (string)(I('request.sort')) : 'desc';
    $order['id'] = $content;

    // 获取搜索条件
		$real_name       =   I('request.real_name');
    $map['status']   =   array('egt',0);
    if(is_numeric($real_name)){
        $map['id|real_name'] =   array(intval($real_name),array('like','%'.$real_name.'%'),'_multi'=>true);
    }else{
        $map['real_name']    =   array('like', '%'.(string)$real_name.'%');
    }

		$list = $this->lists('user_detail',$map,$order);
		$sex= ['女','男','保密'];
    foreach($list as $key=>&$val){
     	$val['sex'] = $sex[$val['sex']];
     	$val['age'] = round((time()-$val['age'])/3600/24/365);
     	$val['ctime'] = date('Y/m/d',$val['ctime']);
    }
		$this->assign('list',$list);
		$this->display();
	} 


	// 用户的排序
	public function sort(){
		
		$user_detail=new \Admin\Model\MyMemberModel('user_detail');

		$list=$user_detail->mysort();
		// 变量赋值
		$this->assign('list',$list);
		// 模板展示
		$this->display('userlist');
	}
}
